<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

use App\Http\Requests;
use App\Http\Controllers\Controller;
use DB;

class AdminController extends Controller
{
    /*
	*
	*
    */
    public function index()
    {
    	return view('admin.index');
    }

    public function upload()
    {
    	return view('admin.upload');
    }

    public function pic()
    {
        $pic = DB::table('pic')->get(); 
        return view('admin.pic',['pic'=>$pic]);
    }

    public function uploadFile(Request $request)
    {
    	$res = $request->hasFile('img');
    	// dd($res);
        if($res){
            $request->file('img')->move('./images/', $_FILES['img']['name']);
        }else{
            return back();
        }
        

        $res = DB::table('pic')
        ->insert(['pic'=>$_FILES['img']['name']]);
        if($res){
            return redirect('pic');
        }

        return back();
    }

    public function del($id)
    {
        $res = DB::table('pic')
        ->where('id',$id)
        ->delete();
        return back();
    }



    
}
